/**
 * huize Service Inc
 * All Rights Reserved @2018
 */
package com.huize.ladon.apm.common.util;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * 描述: 工具类，其代码从{@code com.hzins.bsp.common.util.HzObjectMapper.java} 移植过来，减少apm项目依赖
 *
 * @author tianyuliang
 * @version $Id: HzObjectMapperUtils.java, v0.1 2019/4/12
 */
public class HzObjectMapperUtils extends ObjectMapper {

    private static final long serialVersionUID = 3128075518408868892L;

    @SuppressWarnings("unchecked")
    public <T> T readValue(String content, Type type) throws IOException, JsonParseException, JsonMappingException {
        return (T) _readMapAndClose(_jsonFactory.createParser(content), _typeFactory.constructType(type));
    }

}
